
package me.zhengjie.repository;

import me.zhengjie.domain.AppMessageTo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

/**
* @website https://el-admin.vip
* @author IQW
* @date 2022-07-18
**/
public interface AppMessageToRepository extends JpaRepository<AppMessageTo, Integer>, JpaSpecificationExecutor<AppMessageTo> {

    @Query(value = "SELECT * FROM app_message_to WHERE" +
            " user_id= ?1 and msg_id = ?2 limit 1", nativeQuery = true)
    AppMessageTo queryByUserIdAndMsgId(Integer userId, Integer msgId);


    @Query(value = "SELECT count(id) FROM app_message_to WHERE" +
            " user_id= ?1 and status = 0", nativeQuery = true)
    Integer msgCount(Integer userId);
}